Skip to content

fix: Adding text-enabled plugins failed after adding first plugin #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 23, 2025

Conversation

fsbraun
Copy link
Member

@fsbraun fsbraun commented May 23, 2025

This fixes #90, a regression introduced in #87
Also updates the readme, fixing #89

Summary by Sourcery

Fix plugin form loading regression after the first plugin by renaming the form loader, unconditionally processing the dataBridge, and updating tests to use the new method; enhance RTEConfig with additional configuration options.

Bug Fixes:

  • Rename loadForm to loadPluginForm and update its calls to restore plugin form loading.
  • Always invoke processDataBridge when loading plugins to ensure proper dataBridge handling.

Enhancements:

  • Add admin_css, inline_editing, and child_plugin_support options to the RTEConfig class.

Tests:

  • Update the JavaScript test to call loadPluginForm instead of loadForm.

Summary by Sourcery

Restore and fix plugin form loading in CMSEditor, unify dataBridge processing for all plugin additions, extend RTEConfig with new options, and update related tests and documentation.

Bug Fixes:

  • Rename loadForm to loadPluginForm and update its calls to restore text-enabled plugin form loading.
  • Always invoke processDataBridge when loading plugins to ensure proper dataBridge handling.

Enhancements:

  • Add admin_css, inline_editing, and child_plugin_support options to the RTEConfig class.

Build:

  • Bump package version to 0.8.6.

Documentation:

  • Update README and changelog to reflect bug fixes and new configuration options.

Tests:

  • Update JavaScript test to call loadPluginForm instead of loadForm.

Copy link
Contributor

sourcery-ai bot commented May 23, 2025

Reviewer's Guide

This PR restores plugin form loading by renaming loadForm to loadPluginForm and unconditionally invoking processDataBridge, enhances the RTEConfig API with new options, updates tests, and bumps the package version with accompanying documentation updates.

Sequence Diagram for Updated Plugin Form Loading

sequenceDiagram
    participant C as CMSEditor
    participant I as iframe
    participant F as form

    C->>I: loadPluginForm(url, ...)
    activate I
    I-->>C: "load" event
    deactivate I
    C->>F: Get form elements from iframe.contentDocument
    C->>C: processDataBridge(form)
    alt onSave callback provided and dataBridge available
        C->>C: onSave(el, form, dataBridge)
    end
Loading

Updated Class Diagram for CMSEditor

classDiagram
    class CMSEditor {
        <<JavaScript Class>>
        +addPlugin(...)
        +addPluginForm(...)
        +loadPluginForm(url, iframe, el, onLoad, onSave)
        +processDataBridge(form)
    }
Loading

Updated Class Diagram for RTEConfig

classDiagram
    class RTEConfig {
        <<Python Class>>
        +name: str
        +config: str
        +js: Iterable[str]
        +css: dict
        +admin_css: Iterable[str]
        +inline_editing: bool
        +child_plugin_support: bool
        +__init__(name, config, js, css, admin_css, inline_editing, child_plugin_support)
    }
Loading

File-Level Changes

Change Details Files
Restore plugin form loader and dataBridge processing
  • Rename loadForm method to loadPluginForm
  • Update addPlugin/addChildPlugin calls to use loadPluginForm
  • Remove conditional around dataBridge invocation
  • Always call processDataBridge on iframe load
  • Adjust JavaScript tests to call loadPluginForm
private/js/cms.editor.js
tests/js/cms.editor.test.js
Extend RTEConfig with new customization options
  • Add admin_css iterable for admin-only CSS files
  • Introduce inline_editing boolean flag
  • Introduce child_plugin_support boolean flag
djangocms_text/editors.py
Bump package version and update documentation
  • Increment version to 0.8.6
  • Add entries for plugin loader fix and RTEConfig enhancements in CHANGELOG
  • Reflect new configuration options and fix references in README
djangocms_text/__init__.py
README.rst
CHANGELOG.rst

Assessment against linked issues

Issue Objective Addressed Explanation
#90 When adding multiple text-enabled plugins (like Link, Icon, Picture) to a Text plugin, the settings from the first plugin are incorrectly applied to subsequent plugins.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

codecov bot commented May 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.61%. Comparing base (df1b635) to head (ff140b2).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #91   +/-   ##
=======================================
  Coverage   81.61%   81.61%           
=======================================
  Files          14       14           
  Lines         941      941           
  Branches      110      110           
=======================================
  Hits          768      768           
  Misses        130      130           
  Partials       43       43           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fsbraun fsbraun marked this pull request as ready for review May 23, 2025 07:06
@fsbraun fsbraun merged commit 13a222e into main May 23, 2025
22 checks passed
@fsbraun fsbraun deleted the fix/add-plugins branch May 23, 2025 07:06
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @fsbraun - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -65,7 +65,7 @@ describe('CMSEditor', () => {
const el = document.getElementById('editor1');
document.body.appendChild(iframe);

editor.loadForm('about:blank', iframe, el, () => {
editor.loadPluginForm('about:blank', iframe, el, () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (testing): Test should cover the multi-plugin scenario described in the bug.

Please add a test that adds a plugin, then adds a second one, to verify that loadPluginForm and processDataBridge handle multiple plugins as described in bug #90.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding a plugin from either tiptap or ckeditor fails
1 participant